From 46d892e08d9a93c4111c94ebdd07dc90ad61f300 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 14 Apr 2007 14:47:14 +0000 Subject: [PATCH] Allow floating values in UTM coordinates. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2731 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/util.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gpsbabel/util.c b/gpsbabel/util.c index 617199e7d..225fe65fa 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -434,8 +434,16 @@ lrtrim(char *buff) c = buff; while ((*c != '\0') && ((unsigned char)*c <= ' ')) c++; + + if (c != buff) { + char *src = c; + char *dst = buff; + + while (*src) *dst++ = *src++; + *dst = '\0'; + } - return c; + return buff; } /* @@ -1009,7 +1017,8 @@ parse_coordinates(const char *str, int datum, const grid_type grid, unsigned char lathemi, lonhemi; int deg_lat, deg_lon, min_lat, min_lon; char map[3]; - int utmz, utme, utmn; + int utmz; + double utme, utmn; char utmc; int valid, result, ct; double lx, ly; @@ -1065,14 +1074,13 @@ parse_coordinates(const char *str, int datum, const grid_type grid, break; case grid_utm: - format = "%d %c %d %d%n"; + format = "%d %c %lf %lf%n"; ct = sscanf(str, format, &utmz, &utmc, &utme, &utmn, &result); valid = (ct == 4); if (valid) { - valid = GPS_Math_UTM_EN_To_Known_Datum(&lat, &lon, utme, utmn, utmz, utmc, datum); - if (! valid) + if (! GPS_Math_UTM_EN_To_Known_Datum(&lat, &lon, utme, utmn, utmz, utmc, datum)) fatal("%s: Unable to convert UTM coordinates (%s)!\n", module, str); } @@ -1085,9 +1093,10 @@ parse_coordinates(const char *str, int datum, const grid_type grid, module, (int)grid); } - if (!valid) { - warning("%s: sscanf error using format \"%s\"\n", module, format); - fatal( "%s: could not convert data \"%s\"!\n", module, str); + if (! valid) { + warning("%s: sscanf error using format \"%s\"!\n", module, format); + warning("%s: parsing has stopped at parameter number %d.\n", module, ct); + fatal("%s: could not convert coordinates \"%s\"!\n", module, str); } if (lathemi == 'S') lat = -lat; -- 2.30.2